<?php
namespace app\msgapi\controller;

use app\BaseController;
use app\msgapi\service\HuihuaMsgService;
use app\Request;

/**
 * 会话消息控制器
 */
class Hschat extends BaseController
{
    protected HuihuaMsgService $service;
    public function __construct(HuihuaMsgService $service)
    {
        parent::__construct(app());
        $this->service = $service;
    }

    /**获取指定成员聊天对象列表
     * @param Request $request
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getMemberChatObject(Request $request)
    {
        $data = $request->only(['page','limit','order','sort','userid','is_crowd','cust_id','title','chat_id'],'post');
        return $this->service->getMemberChatObject($data,$request->admin_groupid,$request->adminid);
    }

    /**获取指定聊天对象聊天记录
     * @param Request $request
     * @return \think\response\Json
     */
    public function getChatLst(Request $request)
    {
        $data = $request->only(['group_id','groupchat_chatid','page','limit','order','sort','keyword','start_time','end_time','msgtype','is_output']);
        return $this->service->getChatLst($data,$request->admin_groupid,$request->adminid);
    }

    /**根据消息id获取消息(撤回消息等用)
     * @return \think\response\Json
     */
    public function getChatInfo(Request $request)
    {
        $data = $request->only(['msgid'],'post');
        return $this->service->getChatInfo($data);
    }

    /**消息审计列表
     * @param Request $request
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getChatAuditLst(Request $request){
        $data = $request->only(['page','limit','order','sort','keyword','start_time','end_time','msgtype','userid','gettype','is_output']);
        return $this->service->getChatAuditLst($data,$request->admin_groupid,$request->adminid);
    }
}